#coding: utf-8
import re

today_sell_szhome='http://market.szhome.com/Sell_Search2.aspx?c2VhcmNodHlwZT0wJmRhdGU9MSZrZXl3b3JkPSVlNiViMyVhMiVlNiU4OSU5OCVlOCU4ZiViMiVlOCVhZiViYQ=='
all_sell_szhome='http://market.szhome.com/Sell_Search2.aspx?c2VhcmNodHlwZT0wJmtleXdvcmQ9JWU2JWIzJWEyJWU2JTg5JTk4JWU4JThmJWIyJWU4JWFmJWJh'

detail_sell_szhome='http://market.szhome.com/Sell_View.aspx?MessageID=%s'

re_buildingList=re.compile(r'(?:<tr align="center" style="height:22px;'
       r'|<tr align="center" style="background-color:#E8F2F9;height:22px;)'
       r'.*?(>|\s)<a id="ctl00_ContentPlace_gvSellResult_ctl\d+_hy1" href="Sell_View\.aspx\?MessageID=(\d+).*?<span id="ctl00_ContentPlace_gvSellResult_ctl\d+_L5">(\d+)</span>.*?<td>(\d{4}-\d{2}-\d{2})</td>.*?</tr>',re.DOTALL)

re_page=re.compile(ur'页次：1/(\d+)页'.encode('gbk'))

re_detail=re.compile(ur"""<span id="ctl00_ContentPlace_lblTitle" style="font-size:15px;font-weight:bold;">(?P<title>.*?)</span>.*<span id="ctl00_ContentPlace_lblComeFrom">(?:<a href='Shop/CompanyShop\.aspx\?cid=\d+' target='_blank' style='color:blue;'>)?(?P<agent>[^\[]*)(?:(?:\[更多\])?</a>)?.*</span>.*<span id="ctl00_ContentPlace_lblApartmentCategory">(?P<typeOfFlat>.*?)</span>.*<span id="ctl00_ContentPlace_lblBuildingArea">(?P<squareFootage>\d+(?:\.\d{1,2})?) ㎡</span>.*<span id="ctl00_ContentPlace_lblContact">(?P<contactName>.*?)</span>.*<span id="ctl00_ContentPlace_lblEmail">(?:(?:  -  )|(?P<email>.*?))</span>.*<span id="ctl00_ContentPlace_lblPhone">(?P<phoneNum>\d+(?:,\d+)*)</span>.*<span id="ctl00_ContentPlace_lblBuildingAge">(?:(?:  -  )|(?:(?P<yearBuilt>\d{1,2}) 年))</span>.*<span id="ctl00_ContentPlace_lblFloor">(?:(?:  -  )|(?:(?P<floor>\d{1,2}) 层))</span>.*<span id="ctl00_ContentPlace_lblOrientation">(?P<exposure>.*?)</span>.*<span id="ctl00_ContentPlace_lblTotalFloor">(?:(?:  -  )|(?:(?P<totalFloors>\d{1,2}) 层))</span>.*<span id="ctl00_ContentPlace_lblDecorationCategory">(?P<decoration>.*?)</span>.*<span id="ctl00_ContentPlace_cblBaseEquipment"><input id="ctl00_ContentPlace_cblBaseEquipment_0" type="checkbox" name="ctl00\$ContentPlace\$cblBaseEquipment\$0" (?P<equipment0>checked="checked" )?/><label for="ctl00_ContentPlace_cblBaseEquipment_0">水</label><input id="ctl00_ContentPlace_cblBaseEquipment_1" type="checkbox" name="ctl00\$ContentPlace\$cblBaseEquipment\$1" (?P<equipment1>checked="checked" )?/><label for="ctl00_ContentPlace_cblBaseEquipment_1">电</label><input id="ctl00_ContentPlace_cblBaseEquipment_2" type="checkbox" name="ctl00\$ContentPlace\$cblBaseEquipment\$2" (?P<equipment2>checked="checked" )?/><label for="ctl00_ContentPlace_cblBaseEquipment_2">管道煤气</label><input id="ctl00_ContentPlace_cblBaseEquipment_3" type="checkbox" name="ctl00\$ContentPlace\$cblBaseEquipment\$3" (?P<equipment3>checked="checked" )?/><label for="ctl00_ContentPlace_cblBaseEquipment_3">家具</label><input id="ctl00_ContentPlace_cblBaseEquipment_4" type="checkbox" name="ctl00\$ContentPlace\$cblBaseEquipment\$4" (?P<equipment4>checked="checked" )?/><label for="ctl00_ContentPlace_cblBaseEquipment_4">电话线路</label><input id="ctl00_ContentPlace_cblBaseEquipment_5" type="checkbox" name="ctl00\$ContentPlace\$cblBaseEquipment\$5" (?P<equipment5>checked="checked" )?/><label for="ctl00_ContentPlace_cblBaseEquipment_5">有线电视线路</label><input id="ctl00_ContentPlace_cblBaseEquipment_6" type="checkbox" name="ctl00\$ContentPlace\$cblBaseEquipment\$6" (?P<equipment6>checked="checked" )?/><label for="ctl00_ContentPlace_cblBaseEquipment_6">宽带线路</label></span>.*<span id="ctl00_ContentPlace_cblWiring"><input id="ctl00_ContentPlace_cblWiring_0" type="checkbox" name="ctl00\$ContentPlace\$cblWiring\$0" (?P<cblWiring0>checked="checked" )?/><label for="ctl00_ContentPlace_cblWiring_0">电话</label><input id="ctl00_ContentPlace_cblWiring_1" type="checkbox" name="ctl00\$ContentPlace\$cblWiring\$1" (?P<cblWiring1>checked="checked" )?/><label for="ctl00_ContentPlace_cblWiring_1">电视</label><input id="ctl00_ContentPlace_cblWiring_2" type="checkbox" name="ctl00\$ContentPlace\$cblWiring\$2" (?P<cblWiring2>checked="checked" )?/><label for="ctl00_ContentPlace_cblWiring_2">冰箱</label><input id="ctl00_ContentPlace_cblWiring_3" type="checkbox" name="ctl00\$ContentPlace\$cblWiring\$3" (?P<cblWiring3>checked="checked" )?/><label for="ctl00_ContentPlace_cblWiring_3">热水器</label><input id="ctl00_ContentPlace_cblWiring_4" type="checkbox" name="ctl00\$ContentPlace\$cblWiring\$4" (?P<cblWiring4>checked="checked" )?/><label for="ctl00_ContentPlace_cblWiring_4">洗衣机</label><input id="ctl00_ContentPlace_cblWiring_5" type="checkbox" name="ctl00\$ContentPlace\$cblWiring\$5" (?P<cblWiring5>checked="checked" )?/><label for="ctl00_ContentPlace_cblWiring_5">空调</label></span>.*<span id="ctl00_ContentPlace_lblDetail">(?:(?:  -  )|(?P<description>.*?))</span>""".encode('gbk'),re.DOTALL|re.IGNORECASE)